package vn.gq.app4vn.doctruyen;


import vn.gq.app4vn.doctruyen.AdmobAdLoader.AdLoaderListener;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class StartupActivity extends Activity {

	private boolean pushedScreen = false;
	private Handler mHandler = new Handler();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_startup);
		AdmobAdLoader adLoader = new AdmobAdLoader(this);
		adLoader.load(new AdLoaderListener() {
			
			@Override
			public void onDone() {
				mHandler.removeCallbacks(pushScreenRn);
				mHandler.postDelayed(pushScreenRn, 1000);
			}
		});
		mHandler.postDelayed(pushScreenRn, 6000);
	}
	
	private Runnable pushScreenRn = new Runnable() {
		
		@Override
		public void run() {
			pushScreen();
		}
	};
	
	public void pushScreen() {
		if (!pushedScreen) {
			pushedScreen = true;
			Intent intent = new Intent(StartupActivity.this, HomeActivity.class);
			startActivity(intent);
			finish();
		}
	}
}
